from django.db import models
from users.models import UserModel


# 患者信息模型类
class PatientModel(models.Model):
    PREGNANCY_STATUS_CHOICES = {
        (0, '无'),
        (1, '怀孕中'),
        (2, '哺乳中'),
    }
    name = models.CharField(max_length=100, verbose_name='患者姓名')
    sex = models.BooleanField(default=0, verbose_name='性别', help_text='0：表示男 1：表示女')
    birthday = models.DateField(verbose_name='出生年月')
    weight = models.DecimalField(max_digits=5, decimal_places=2, verbose_name='体重')
    allergy_history = models.BooleanField(default=0, verbose_name='过敏史', help_text='0：表示无 1：表示有')
    allergy_history_content = models.TextField(null=True, blank=True, verbose_name='过敏史内容')
    illness_history = models.BooleanField(default=0, verbose_name='过往病史', help_text='0：表示无 1：表示有')
    illness_history_content = models.TextField(null=True, blank=True, verbose_name='过往病史内容')
    liver_function = models.BooleanField(default=0, verbose_name='肝功能', help_text='0：表示正常 1：表示异常')
    renal_function = models.BooleanField(default=0, verbose_name='肾功能', help_text='0：表示正常 1：表示异常')
    pregnancy_status = models.SmallIntegerField(choices=PREGNANCY_STATUS_CHOICES, default=0, null=True, blank=True, verbose_name='孕育情况')
    user = models.ForeignKey(to=UserModel, related_name='patient_list', on_delete=models.CASCADE, null=True,
                             blank=True, db_constraint=False, verbose_name='用户')

    class Meta:
        db_table = 'patient_info'
        verbose_name_plural = '患者信息表'

    def __str__(self):
        return self.name
